<?php
namespace App\Http\Controllers\Api;

use App\Models\BannerModel;
use App\Models\TitleScrollModel;
use App\Models\UserModel;
use App\Requests\CheckVersionRequest;
use App\Services\AppService;
use Carbon\Carbon;
use Framework\BaseController;
use Framework\Hope;
use Illuminate\Support\Facades\Log;
use Illuminate\Http\Request;

/** 版本控制器
 * Class AppController
 * @package App\Http\Controllers\Api
 */
class AppController extends BaseController
{

    public function checkVersion(CheckVersionRequest $request , AppService $service)
    {

        $type = $request->type();
        $version = $request->version();

        $info = $service->getVersionInfo($type, $version);
        $this->retSuccess($info);
    }





    public function getNickname(Request $request)
    {
        $user_id = $request->input('user_id');
        if($user_id){
            $nickname = UserModel::where('id',$user_id)->value('nickname');
            $this->retSuccess($nickname);
        }else{
            return false;
        }
    }

    public function getBanner(Request $request)
    {
        $type = $request->input('type',1);
       $info =  BannerModel::query()->where(['status'=>1,'type'=>$type])->get();
        $this->retSuccess($info);
    }


    public function getNotice()
    {
        $info = TitleScrollModel::query()->where('status',1)->get();
        $this->retSuccess($info);
    }
}
